home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
3_0
/
APPFILET
/
APPFILET.C
next >
Wrap
C/C++ Source or Header
|
1989-04-14
|
2KB
|
58 lines
/*
Simple Think C program to report what files we've been asked to open.
When you start up a Macintosh program by opening a document or printing
a document, or by selecting both the application and the document, the
application gets this information passed to it.
To try this code, In Think C, create a project with this file, MacTraps,
and Stdio.
In MPW 3.0, issue the following commands:
c aft.c
link {CLibraries}CRunTime.o {CLibraries}StdCLib.o ╢
{CLibraries}CInterface.o {Libraries}Interface.o aft.c.o -o aft
Set the program creator to be some arbitrary four character type (I used
'FooB'. Create some files, and change their creator to 'FooB' using
ResEdit or your favorite file manipulator. Double click on the text
file, or select the file and choose "Print" from the Finder File menu.
*/
#ifdef macintosh /* MPW */
#include "SegLoad.h"
#endif
#ifdef THINK_C
#include "SegmentLdr.h"
#endif
/* procedure prototypes. */
void main(void);
void ShowAppFiles(short);
int printf(char *, ...);
void
main()
{
short message; /* whether to open or print the files */
short count; /* how many files to open or print */
AppFile app; /* structure holding vRefNum, fType, version, pascal name */
short i;
CountAppFiles(&message, &count);
if (count > 0)
{
if (message == appOpen)
printf("We were asked to open these files:\n");
else if (message == appPrint)
printf("We were asked to print these files:\n");
for (i = 1; i <= count; i++ )
{
GetAppFiles(i, &app);
printf("app.fName[%d] = %P\n", i, app.fName);
}
}
else
printf("we weren't asked to do anything.\n");
}